package com.atguigu.gulimall.product.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gulimall.product.service.SkuInfoService;
import com.atguigu.gulimall.product.vo.SkuItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @Author lhj
 * @Create 2024/1/27 9:57
 * @Version 1.0
 */
@Slf4j
@Controller
public class ItemController {
    
    @Autowired
    SkuInfoService skuInfoService;
    
    @GetMapping(value = {"/{skuId}.html"})
    public String skuItem(@PathVariable Long skuId, Model model) {
        log.info("skuItem req: {}", skuId);
        SkuItemVo skuItemVo = skuInfoService.item(skuId);
        log.info("skuItem res: {}", JSONObject.toJSONString(skuItemVo));
        model.addAttribute("item", skuItemVo);
        return "item";
    }
    
    
    
}
